package com.ways.poi.controller;

import com.ways.poi.entity.LexusModel;
import com.ways.poi.service.LexusModelService;
import com.ways.poi.util.ExcelUtil;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class PoiController {

    @Resource
    LexusModelService lexusModelService;

    @GetMapping("/poi")
    public ResponseEntity<byte[]> downloadPoi() {
        List<LexusModel> list = lexusModelService.selectModelList();
        ExcelUtil<LexusModel> excelUtil = new ExcelUtil<>(LexusModel.class);
        return excelUtil.exportExcel(list, "车型数据");
    }

    @GetMapping("/importTemplate")
    public ResponseEntity<byte[]> importTemplate() {
        ExcelUtil<LexusModel> excelUtil = new ExcelUtil<>(LexusModel.class);
        return excelUtil.importTemplateExcel("车型数据");
    }
}
